//
//  HLHomeCellBottomView.m
//  weibo-OC
//
//  Created by 黄力 on 15/12/21.
//  Copyright © 2015年 HLTest. All rights reserved.
//

#import "HLHomeCellBottomView.h"
#import <Masonry.h>
#import "UIView+HLRespond.h"

@interface HLHomeCellBottomView ()

//转发
@property (nonatomic,strong) UIButton *retweetBtn;
//评论按钮
@property (nonatomic,strong) UIButton *commentBtn;
//赞按钮
@property (nonatomic,strong) UIButton *likeBtn;

@end

@implementation HLHomeCellBottomView

- (instancetype)init
{
    self = [super init];
    if (self) {
        //设置界面
        [self setupUI];
    }
    return self;
}

//设置界面
- (void)setupUI {
    //添加子控件
    [self addSubview:self.retweetBtn];
    [self addSubview:self.commentBtn];
    [self addSubview:self.likeBtn];
    
    UIView *lineOne = [self createSepararteLine];
    UIView *lineTwo = [self createSepararteLine];
    [self addSubview:lineOne];
    [self addSubview:lineTwo];
    
    //设置约束
    //转发
    [self.retweetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.height.equalTo(self);
    }];
    
    //分割线
    [lineOne mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.centerX.equalTo(self.retweetBtn.mas_right);
        make.width.equalTo(@1);
        make.height.equalTo(self).multipliedBy(0.4);
    }];
    
    //评论按钮
    [self.commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(self.retweetBtn);
        make.left.equalTo(self.retweetBtn.mas_right);
    }];
    
    //分割线
    [lineTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.centerX.equalTo(self.commentBtn.mas_right);
        make.width.equalTo(@1);
        make.height.equalTo(self).multipliedBy(0.4);
    }];
    
    //赞按钮
    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(self.retweetBtn);
        make.left.equalTo(self.commentBtn.mas_right);
        make.right.equalTo(self);
    }];
    
    //添加评论按钮的点击响应事件
    [self.commentBtn addTarget:self action:@selector(clickCommentBtn) forControlEvents:UIControlEventTouchUpInside];
}

//评论按钮的点击响应事件
- (void)clickCommentBtn {
    //获取导航控制器
    UINavigationController *nav = [self.commentBtn getNavigationController];
    NSLog(@"%@",nav);
}

//创建分割线
- (UIView *)createSepararteLine {
    //创建
    UIView *view = [[UIView alloc] init];
    //设置背景颜色
    view.backgroundColor = [UIColor blackColor];
    return view;
}


#pragma mark - 懒加载子控件
//转发
- (UIButton *)retweetBtn {
    if (_retweetBtn == nil) {
        _retweetBtn = [[UIButton alloc] initWithTitle:@"转发" withTitleFont:12 withImageName:@"timeline_icon_retweet" withBackImageName:@"timeline_card_middle_background" withTitleColor: [UIColor lightGrayColor]];
    }
    return _retweetBtn;
}

//评论
- (UIButton *)commentBtn {
    if (_commentBtn == nil) {
        _commentBtn = [[UIButton alloc] initWithTitle:@"评论" withTitleFont:12 withImageName:@"timeline_icon_comment" withBackImageName:@"timeline_card_middle_background" withTitleColor: [UIColor lightGrayColor]];
    }
    return _commentBtn;
}

//赞
- (UIButton *)likeBtn {
    if (_likeBtn == nil) {
        _likeBtn = [[UIButton alloc] initWithTitle:@"赞" withTitleFont:12 withImageName:@"timeline_icon_unlike" withBackImageName:@"timeline_card_middle_background" withTitleColor: [UIColor lightGrayColor]];
    }
    return _likeBtn;
}


@end
